<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.request.URLInformation');


	class URLInformationTest extends AbstractTekunaTestCase {

		public function testGettersSetters() {

			// get instance
			$objUI = new URLInformation();

			// test the getters and setters
			$sRequestURL = '/foo/bar/baz.html';
			$objUI -> setRequestURL($sRequestURL);
			$this -> assertIdentical($objUI -> getRequestURL(), $sRequestURL);

			$sModuleBaseURL = '/myModule/';
			$objUI -> setModuleBaseURL($sModuleBaseURL);
			$this -> assertIdentical($objUI -> getModuleBaseURL(), $sModuleBaseURL);

			$sComponentURL = '/myComponent/action.html';
			$objUI -> setComponentURL($sComponentURL);
			$this -> assertIdentical($objUI -> getComponentURL(), $sComponentURL);

			$arrParts = array('actions', 'index', 'html');
			$objUI -> setMatchedURLParts($arrParts);
			$this -> assertIdentical($objUI -> getMatchedURLParts(), $arrParts);
		}


		public function testRelativeBasePath() {

			// get instance
			$objUI = new URLInformation();

			// test different paths
			$objUI -> setRequestURL('/foo/bar/baz.html');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '../../');

			$objUI -> setRequestURL('/foo/bar/');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '../../');

			$objUI -> setRequestURL('/foo/bar');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '../');

			$objUI -> setRequestURL('/foo/');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '../');

			$objUI -> setRequestURL('/index.html');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '');

			$objUI -> setRequestURL('/');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '');

			$objUI -> setRequestURL('');
			$this -> assertIdentical($objUI -> getRelativeBasePath(), '');
		}
	}



